function[Hx1,Hy1,Hr1] = read_chile_res(File_1);


%File_1 = 'D:\Manoj\tsunami\2010_Chile_Easter_Island_data\modeling\resfiles\tsu117.res';
fid = fopen(File_1, 'r', 'n');

if fid == -1,
    fprintf('Error in reading a file\n');
    Hx1=0;
    Hy1=0;
    Hr1=0;
    return;
end;

LBlock = fread(fid, 1, 'long');
NO = fread(fid, 1, 'long');
Period = fread(fid, 1, 'double'); 
np = fread(fid, 1, 'long');
nt = fread(fid, 1, 'long');
theta_first = fread(fid, 1,'double'); %ONLY LAT BAND CASE
dtheta = fread(fid, nt,'double');%ONLY LAT BAND CASE
fseek(fid, LBlock, 'bof'); % LBlock if file is written on sun
Hpr = fread(fid, [nt np], 'float');
Hpi = fread(fid, [nt np], 'float');
Htr = fread(fid, [nt np], 'float');
Hti = fread(fid, [nt np], 'float');
Hrr = fread(fid, [nt np], 'float');
Hri = fread(fid, [nt np], 'float');

Hx1  = -(Htr+j*Hti)*100*4.*pi;
Hy1  =  (Hpr+j*Hpi)*100*4.*pi;
Hr1  =  (Hrr+j*Hri)*100*4.*pi;

fclose(fid);

